import { createStore, applyMiddleware } from 'redux';
import logger from 'redux-logger'
// 初始化数据
const initState = {
  userInfo: {}
}

// 纯函数--发生dispatch action执行
const reducer = (prevState = initState, action) => {
  // Reducers 指定了应用状态的变化如何响应 actions 并发送到 store 的
  switch(action.type) {
    case 'updateUserInfo': {
      return {
        userInfo: action.payload
      }
    }
  }
  return prevState
}

// 创建仓库
const store = createStore(reducer, applyMiddleware(logger));


export default store

